#增加:格式:dict1[key] = value
#特点:按照上面的格式，如果在字典中存在同名的key，则发生值得替换(后面的值覆盖原来的)
#如果没有同名的key，则实现的是添加功能(key:vlue添加到字典中)
dict1 = {}
dict1['brand'] = '华为'
print(dict1)
dict1['brand'] = 'oppo'
print(dict1)
dict1['type'] = 'p30 pro'
dict1['price'] = '7850'
dict1['color'] = '黑色'
print(dict1)

'''
案例：
  用户注册功能
  username
  password
  email
  phone
'''
print('---------欢迎来到xxx用户注册---------')
database = []
while True:
    username = input('输入用户名:')
    password = input('输入密码:')
    repassword = input('输入确认密码:')
    email = input('输入邮箱:')
    phone = input('输入手机号:')
    user = {}
    user['username'] = username
    if password == repassword:
        user[password] = password
    else:
        print('两次密码不一致！请重新输入....')
        continue
    user['email'] = email
    user['phone'] = phone
    database.append(user)
    answer = input('是否继续注册?(y/n)')
    if answer != 'y':
        break
print(database)


